package com.promis.party.ui.learneducation;

import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.FrameLayout;

import com.promis.party.R;
import com.promis.party.helper.ContextHelper;
import com.promis.party.ui.learneducation.onlinelearning.exam.OnlinExam;
import com.promis.party.ui.learneducation.office.LearnEducationActivity;
import com.promis.party.ui.learneducation.onlinelearning.optionalcourse.OptionalActivity;
import com.promis.party.ui.learneducation.onlinelearning.requiredcourse.RequriedCourseActivity;
import com.promis.widget.ImageTextView;

/**
 * Created by zcy on 2018/9/25.
 */

public class LearnEducationFragment extends Fragment {

    private ContextHelper contextHelper;
    private ImageTextView imgvRequiredCourse;
    private ImageTextView imgvOptionalCourse;
    private ImageTextView imgvOnlinExam;
    private ImageTextView imgvLearnNineteen;
    private ImageTextView imgvPartyConstitution;
    private ImageTextView imgvSpeech;

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        FrameLayout rootLayout = (FrameLayout) inflater.inflate(R.layout.fragment_learn_education, container, false);
        imgvRequiredCourse = rootLayout.findViewById(R.id.fragment_learn_education_txtv_daibangongwen);
        imgvOptionalCourse = rootLayout.findViewById(R.id.fragment_learn_education_txtv_xuanxiuke);
        imgvOnlinExam = rootLayout.findViewById(R.id.fragment_learn_education_txtv_online_exam);
        imgvLearnNineteen = rootLayout.findViewById(R.id.fragment_learn_education_txtv_xuexishijiuda);
        imgvPartyConstitution = rootLayout.findViewById(R.id.fragment_learn_education_txtv_dangzangdanggui);
        imgvSpeech = rootLayout.findViewById(R.id.fragment_learn_education_txtv_xiliejianghua);

        initData();
        initListener();
        return rootLayout;
    }

    private void initData() {
        contextHelper = new ContextHelper(getContext());
    }

    private void initListener() {
        imgvRequiredCourse.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent(getContext(), RequriedCourseActivity.class);
                startActivity(intent);
            }
        });

        imgvOptionalCourse.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent(getContext(), OptionalActivity.class);
                startActivity(intent);
            }
        });

        imgvOnlinExam.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent(getContext(), OnlinExam.class);
                startActivity(intent);
            }
        });

        imgvLearnNineteen.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent(getContext(), LearnEducationActivity.class);
                intent.putExtra("nineteen", "nineteen");
                startActivity(intent);
            }
        });

        imgvPartyConstitution.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent(getContext(), LearnEducationActivity.class);
                intent.putExtra("partyconstitution", "partyconstitution");
                startActivity(intent);
            }
        });

        imgvSpeech.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent(getContext(), LearnEducationActivity.class);
                intent.putExtra("speech", "speech");
                startActivity(intent);
            }
        });
    }

//    public void httpFindDynamicList() {
//        HttpJsonParams params = new HttpJsonParams();
//        params.add("interest",1);
//        if (UserPreferences.getInstance(getContext()).exists()) {
//            params.add("userId", UserPreferences.getInstance(getContext()).getId());
//        }
//        String url = contextHelper.getServiceUrl(R.string.findInterestDynamicList);
//        new HttpClient<JsonList<Dynamic>>(getContext()) {
//            @Override
//            protected void onSuccess(JsonList<Dynamic> result) {
//                dynamicList = result.getDataList();
//                adptAdopt.notifyDataSetChanged(dynamicList);
//            }
//        }.postAsyn(url, params);
//    }
}